package com.ruoyi.blog.controller;

import com.ruoyi.blog.domain.vo.ResultConfigVo;
import com.ruoyi.blog.service.IBlogConfigService;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/blog/config")
public class BlogConfigController {

    @Autowired
    private IBlogConfigService iBlogConfigService;

    /**
     * 列表数据
     * @return
     */
    @PreAuthorize("@ss.hasPermi('blog:config:list')")
    @GetMapping("/list")
    public AjaxResult list() {
        return AjaxResult.success(iBlogConfigService.getBlogWebConfig() );
    }


    @PreAuthorize("@ss.hasPermi('blog:config:save')")
    @PutMapping
    public AjaxResult save(@RequestBody ResultConfigVo configVo) {
        return iBlogConfigService.updateBlogConfig(configVo) ? AjaxResult.success() : AjaxResult.error("修改配置信息失败！");

    }
}
